import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;

import lhxia.translater.http.server.HttpServer;


public class test {
	static int i = 100;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		final HttpServer server = new HttpServer();
		new Thread(new Runnable() {

			@Override
			public void run() {
				try {
					server.start(8856);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}).start();
		try {
			Thread.sleep(2000);
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}
		
		while(i-- > 0){
			
				new Thread(new Runnable() {
					
					@Override
					public void run() {
					try {
						Socket so = new Socket();
//						try {
//							Thread.sleep((long) (Math.random() * 10000));
//						} catch (InterruptedException e) {
//							// TODO Auto-generated catch block
//							e.printStackTrace();
//						}
						so.connect(new InetSocketAddress("192.168.1.5", 8856));
//						System.out.println("connect " + i);
						while(true){
							so.getOutputStream().write(new byte[]{5,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7});
							so.getOutputStream().flush();
							try {
								Thread.sleep(100);
							} catch (InterruptedException e) {
								e.printStackTrace();
							}
						}
						
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
						// TODO Auto-generated method stub
						
					}
				}).start();
//				System.out.println("connect2");
		}
		try {
			Thread.sleep(99999);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
